package com.itheima.blog.article.controller.web;

import com.itheima.blog.article.dto.AnswerDto;
import com.itheima.blog.article.query.CommentQuery;
import com.itheima.blog.article.query.PageQueryDTO;
import com.itheima.blog.article.service.ITCommentService;
import com.itheima.blog.article.vo.ReplyVO;
import com.itheima.common.domain.PageResDto;
import com.itheima.common.domain.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/web/owner")
@Api(tags ="用户端评论详情相关接口")
@RequiredArgsConstructor
public class CommentController {

    private final ITCommentService commentService;

    @ApiOperation("文章评论查询")
    @GetMapping("/comment")
    public PageResDto<ReplyVO> findPageComment(PageQueryDTO pageQueryDTO){
        return commentService.findPageComment(pageQueryDTO);
    }

    @ApiOperation("新增回复评论")
    @PostMapping("/comment/answer")
    public R saveAnswer(@RequestBody AnswerDto answerDto){
         commentService.saveAnswer(answerDto);
        return R.ok("回复成功");
    }

    @ApiOperation("用户端删除评论")
    @DeleteMapping("/del")
    public R<String> delMyComment(CommentQuery query){
        commentService.delMyComment(query);
        return R.ok("删除成功");
    }
}
